package cn.edu.sjtu.se.dslab.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.edu.sjtu.se.dslab.action.bean.PageBean;
import cn.edu.sjtu.se.dslab.component.data.AvionicsEquipment;
import cn.edu.sjtu.se.dslab.component.data.EquipmentCategory;
import cn.edu.sjtu.se.dslab.dao.IAvionicsEquipmentDao;
import cn.edu.sjtu.se.dslab.exception.DBException;
import cn.edu.sjtu.se.dslab.service.IAvionicsEquipmentService;

@Service("avionicsEquipmentService")
@Transactional
public class AvionicsEquipmentServiceImpl implements IAvionicsEquipmentService {

	@Resource(name="avionicsEquipmentDao")
	private IAvionicsEquipmentDao avionicsEquipmentDao;
	
	@Override
	public boolean addAvionicsEquipment(AvionicsEquipment equipment) {
		// TODO Auto-generated method stub
		avionicsEquipmentDao.save(equipment);
		return true;
	}

	@Override
	public boolean updateAvionicsEquipment(AvionicsEquipment equipment) {
		// TODO Auto-generated method stub
		avionicsEquipmentDao.update(equipment);
		return true;
	}

	@Override
	public AvionicsEquipment getAvionicsEquipmentById(long id) {
		// TODO Auto-generated method stub
		return avionicsEquipmentDao.queryById(id);
	}

	@Override
	public List<AvionicsEquipment> getAllAvionicsEquipmentList() {
		// TODO Auto-generated method stub
		return avionicsEquipmentDao.queryAll();
	}

	@Override
	public List<AvionicsEquipment> getAvionicsEquipmentByEquipmentCategory(
			EquipmentCategory category) {
		// TODO Auto-generated method stub
		return avionicsEquipmentDao.queryByEquipmentCategory(category);
	}

	@Override
	public PageBean<AvionicsEquipment> getAvionicsEquipmentByPageNum(int pageNo)
			throws DBException {
		// TODO Auto-generated method stub
		return avionicsEquipmentDao.queryByPageNum(pageNo);
	}

	@Override
	public AvionicsEquipment getAvionicsEquipmentByUri(String uri) {
		// TODO Auto-generated method stub
		return avionicsEquipmentDao.queryByUri(uri);
	}

	@Override
	public List<AvionicsEquipment> getAvionicsEquipmentByType(String type) {
		// TODO Auto-generated method stub
		return avionicsEquipmentDao.queryByType(type);
	}

	@Override
	public AvionicsEquipment getAvionicsEquipmentByName(String name) {
		// TODO Auto-generated method stub
		return avionicsEquipmentDao.queryByName(name);
	}

	@Override
	public List<AvionicsEquipment> getAvionicsEquipmentByText(String text) {
		// TODO Auto-generated method stub
		return avionicsEquipmentDao.queryByProperty(text);
	}

}
